/**
 * ç¹å»å¾çè½®æ­
 */
function __ON_IMG_ERROR(e){
	if(/\.(png|jpg|jpeg|bmp|gif)$/i.test(e.src)){
		
	}else if(/\.(mp4|avi|asf|flv|3gp|mkv|wmv|mpg|vob|mov)$/i.test(e.src)) {
		e.dataset.src = e.src;
		e.src = "page/back/reportingFaults/icon-video.jpg";
	}
}
var __SIMPLE_PREVIEW_ITEM_PREPROCESS = function(data){
	if(/\.(mp4|avi|asf|flv|3gp|mkv|wmv|mpg|vob|mov)$/i.test(data.url)){
		return '<video controls="controls" class="preview-video" src="'+data.url+'"></video>';
	}
	
	return '<img src="'+data.url+'">';
}
;(function($,window,document,undefined){
	
	if(!$ || !window){
		return ;
	}
	
	$.fn.sliderUtil = function(settings){
		
		var defaultSettings = {
				imglist:[],
				preprocess:null,//å¾çè·¯å¾èªå®ä¹å½æ°
		};
		
		var options = $.extend({},defaultSettings,settings);
		
		
		var uploadTemple = '<div class="file-name-container-left form-control"'
			+'style="height: auto; min-height: 34px; width: 100%; overflow: hidden;" id="file-container">'
			+'	<div class="fh-img">'
			+'		<div class="box2-img">'
			+'		<img class="img2" src="{{item.url}}" style="width:160px; height:160px;"> <a'
			+'			target="_blank" class="file-a" data-suffix="{{item.suffix}}"'
			+'			data-url="{{item.url}}" data-filename="{{item.filename}}"></a>'
			+'	</div>'
			+'	<div class="fh-img-child">'
			+'		<a class="btn glyphicon glyphicon-trash"'
			+'			onclick="$(this).parent().parent().remove()"'
			+'			style="padding: 4px; background-color: rgba(0, 0, 0, 0); color: #fff;"></a>'
			+'	</div>'
			+'</div>'
			+'<div class="enlarge"></div>'
			+'</div>';
		
		
		this.each(function(index,ele){

			var that = $(this);
			
			this.init = function (){
				
				    
				function initSlider(){
					var html = '<div id="slider-content">'
						+'<div class="img-fangda">'
						+'<div class="img-hide">Ã</div>'
						+'<div class="swiper-container">'
						+'   <div class="swiper-wrapper">'
						+ createSilerHtml()
						+'    </div>'
						+'    <div class="swiper-pagination swiper-pagination-white"></div>'
						+'    <div class="swiper-button-prev swiper-button-white"></div>'
						+'    <div class="swiper-button-next swiper-button-white"></div>'
						+'  </div>'
						+'</div>'
						+'</div>';
					
					    $("#slider-content").remove();
					    $("body").append(html);
				}    
				    
				//init slider content
				function createSilerHtml(){
					var _html = "";
					var data = options.imglist;
					var preprocess = options.preprocess;
					
					if(data && data.length > 0){
						for(var i in data){
							
							var el = preprocess instanceof Function? preprocess(data[i]): '<img src="'+data[i].url+'">';
							_html+=' <div class="swiper-slide">'
							+'	        <div class="swiper-zoom-container">' + el + '</div>'
							+'	      </div>'
						}
					}
					return _html;
				}
				
				//init img show content
				function initCreateShowImg(){
					
				}
				
				
				
				initSlider();
			}
			
			this.bind = function(){
				
				$(".img-hide").on("click",function(){
					$(this).parent(".img-fangda").hide();
				})
				
				that.find("img").on("click",function(){
					var index= that.find("img").index($(this));
					$(".img-fangda").show();
					var swiper = new Swiper('.swiper-container', {
					      zoom: true,
					      initialSlide :index,
					      pagination: {
					        el: '.swiper-pagination',
					      },
					      navigation: {
					        nextEl: '.swiper-button-next',
					        prevEl: '.swiper-button-prev',
					      },
					    });
				})
			}
			
			
			this.init();
			this.bind();
			
			return this;
			
		})
		
		
	}
	
	
})(jQuery,window,document);
